<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>欢迎访问BOSS系统管理中心</title>
<link rel="stylesheet" type="text/css" href="${ctx}/resources/static/other/login_style/normalize.css">
<link rel="stylesheet" type="text/css" href="${ctx}/resources/static/other/login_style/component.css">
<style type="text/css">
	*, *:after, *:before { -webkit-box-sizing: border-box; box-sizing: border-box; }
	.clearfix:before, .clearfix:after { content: ''; display: table; }
	.clearfix:after { clear: both; }

	body {
		background: #fff;
		color: #383a3c;
		font-weight: 400;
		font-size: 1em;
		line-height: 1.25;
		font-family: 'Raleway', Calibri, Arial, sans-serif;
	}

	a, button {
		outline: none;
	}

	a {
		color: #566473;
		text-decoration: none;
	}

	a:hover, a:focus {
		color: #34495e;
	}

	section {
		padding: 1em;
		text-align: center;
	}

	p.ref {
		text-align: center;
		padding: 2em 1em;
	}
</style>

<script src="<c:url value="/resources/static/js/jquery-1.9.1.min.js"/>" type="text/javascript"></script>

<script type="text/javascript">
	//是否开启验证码登录
	var openVerifyCode = false;

	//是否开启ajax登录
	var openAjaxLogin = true;

	$(document).keyup(function(event) {
        if (event.keyCode == 13) {
            $("#loginLink").trigger("click");
        }
    });
	
	function reset(){
		$("#userName").val("");
		$("#password").val("");
		$("#userName").focus();
	}
	
	//客户端校验
    function check() {
        if ($("#userName").val() == "") {
            $.message({
                message:"请输入账户名",
                type:'info'
            });
            $("#userName").focus();
            return false;
        } else {
            $("#userName").val(jQuery.trim($('#userName').val()));
        }

        if ($("#password").val() == "") {
            $.message({
                message:"请输入密码",
                type:'info'
            });
            $("#password").focus();
            return false;
        }
        return true;
    }
	
    //服务器校验
    function severCheck(){
        if(check()){
            //使用ajax登录
            if(openAjaxLogin){
                var userName = $("#userName").val();
                var password = $("#password").val();
                
                $.ajax({
                    type: "post",
                    url: "<c:url value='/login/login'/>",
                    data: {"userName" : userName, "password" : password , "openAjaxLogin" : openAjaxLogin},
                    dataType:'json',
                    cache: false,
                    success: function(data){
                        if(200 == data.code){
                            window.location.href="<c:url value='/'/>";
                        }else if("usererror" == data.msg){
                            $.message({
                                message:"用户名或密码错误",
                                type:'error'
                            });
                            $("#userName").focus();
                        }else{
                            $.message({
                                message:data.msg,
                                type:'error'
                            });
                            $("#userName").focus();
                        }
                    }
                });
            }
        }
    }
</script>
</head>
<body>
<div class="container demo-1">
	<div class="content">
		<div id="large-header" class="large-header">
			<canvas id="demo-canvas"></canvas>
			<div class="logo_box">
				<h3>BOSS系统管理中心</h3>
				<form action="#" name="f" method="post">
					<div class="input_outer">
						<span class="u_user"></span>
						<input name="userName" id="userName" value="admin" class="text" style="color: #FFFFFF !important" type="text" placeholder="请输入账户">
					</div>
					<div class="input_outer">
						<span class="us_uer"></span>
						<input name="password"  id="password" value="123456" class="text" style="color: #FFFFFF !important; position:absolute; z-index:100;" type="password" placeholder="请输入密码">
					</div>
					<div class="mb2"><a class="act-but submit" readonly="readonly" onclick="severCheck();" id="loginLink" href="javascript:;" style="color: #FFFFFF">登录</a></div>
				</form>
				<p style="text-align: center;font-size: 14px;color: white;"><span style="padding-right: 20px;">账户：admin</span>密码：123456</p>
			</div>
		</div>
	</div>
</div>
<link href="${_cdnStaticResourcesPath}/resources/static/js/plugins/message/message.css" type="text/css" rel="stylesheet" />
<script src="${_cdnStaticResourcesPath}/resources/static/js/plugins/message/message.js"></script>
<script src="${ctx}/resources/static/other/login_style/TweenLite.js"></script>
<script src="${ctx}/resources/static/other/login_style/EasePack.js"></script>
<script src="${ctx}/resources/static/other/login_style/demo-1.js"></script>
</body>
</body>
</html>